<template>
  <div class="swAuConductorShort">
    <el-dialog
      title="批量补款"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px">
      <avue-crud
        ref="crud"
        :option="option"
        :data="list">
        <template slot-scope="scope" slot="supPaymentTime">
          <el-date-picker
            v-model="scope.row.supPaymentTime"
            type="date"
            placeholder="补款日期"
            :picker-options="{disabledDate(time) {return time.getTime() > Date.now();}}">
          </el-date-picker>
        </template>
        <template slot-scope="scope" slot="shortAmount">
          <el-input-number v-model="scope.row.shortAmount" controls-position="right" :precision="2"></el-input-number>
        </template>
      </avue-crud>
      <div style="margin-top: 30px;text-align: center">
        <el-button type="primary" @click="queren()">保存</el-button>
        <el-button type="default" @click="closed">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {fenExYuangettoFixed, setSearchFiledsEmpty} from "@/api/subwayRat/commonCheck";
import {
  batchBuKuanSwAuTvmShort ,batchbukuan_option,
} from "@/api/subwayRat/swAuTvm/batchBuKuan.js";
export default {
  components: {},
  name: 'swAuConductorShort',
  data() {
    return {
      type : 0,
      userList:[],
      dialogVisible:false,
      selectKeys:[], //存放对像
      selectKeyVals:[], //存放值
      option: batchbukuan_option,
      listLoading: true,
      listLoadingLimit: true,
      searchForm:{},
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 20, // 每页显示多少条,
        isAsc: false// 是否倒序
      },
      list : [],
      listLimit : [],
      parentThis:null,
    }
  },
  computed: {
  },
  watch: {
  },
  created() {
  },
  mounted() {

  },
  methods: {
    setSearchFiledsEmpty,
    queren(){
      let th=this;
      let rows=JSON.parse(JSON.stringify(this.list));
      this.formatAmount(rows,false);
      batchBuKuanSwAuTvmShort({rows:JSON.stringify(rows)}).then(res=>{
        if(res.data.code==0){
          th.$message.success("操作成功！");
          th.closed();
          th.parentThis.getList();
        }else{
          th.$message.error("操作失败！");
        }
      })
    },
    prev(row){
      this.prevDialog=true;
      this.$nextTick(()=>{
        this.$refs.prev.dialogVisible=true;
        this.$refs.prev.recallShow(row,this);
      })
    },
    getList(rows,parentThis) {
      this.list=JSON.parse(JSON.stringify(rows));
      this.formatAmount(this.list,true);
      this.parentThis=parentThis;
    },
    closed(){
      this.dialogVisible=false;
      this.parentThis.batchBuKuanDialog=false;
    },
    formatAmount(rows,isYuan){
      for(let i=0;i<rows.length;i++){
        let row=rows[i];
        if(isYuan){
          row.shortAmount=fenExYuangettoFixed(row,'shortAmount');
        }else{
          row.shortAmount=Number(row.shortAmount)*100;
        }
      }

    },
    handleFilter(params, done) {
      Object.assign(this.searchForm,params);
      done()
    },
    selectionChange(list){
      this.selectKeys=list;
      this.selectKeyVals=[];
      for(let i=0;i<list.length;i++){
        this.selectKeyVals.push(list[i].id);
      }
    }
  }
}
</script>
<style lang="scss">
</style>
